﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace UniversalGrid
{
    class CalculationTypeToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

            if (value is RowCalculationType && (RowCalculationType)value == RowCalculationType.FixedBoth)
            {
                if (((string)parameter).Contains("FixedBoth"))
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            if(value is RowCalculationType && (RowCalculationType)value == RowCalculationType.FixedCount)
            {
                if(((string)parameter).Contains("FixedCount"))
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            if(value is RowCalculationType && (RowCalculationType) value == RowCalculationType.FixedHeight)
            {
                if (((string)parameter).Contains("FixedHeight"))
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            if (value is RowCalculationType && (RowCalculationType)value == RowCalculationType.Baseline)
            {
                if (((string)parameter).Contains("Baseline"))
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            if (value is ColumnCalculationType && (ColumnCalculationType)value == ColumnCalculationType.FixedBoth)
            {
                if (((string)parameter).Contains("FixedBoth"))
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            if (value is ColumnCalculationType && (ColumnCalculationType)value == ColumnCalculationType.FixedCount)
            {
                if(((string)parameter).Contains("FixedCount"))
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            if (value is ColumnCalculationType && (ColumnCalculationType)value == ColumnCalculationType.FixedWidth)
            {
                if (((string)parameter).Contains("FixedWidth"))
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            if (value is GutterCalculationType && (GutterCalculationType)value == GutterCalculationType.Fixed)
            {
                if (((string)parameter).Contains("Fixed"))
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            if (value is GutterCalculationType && (GutterCalculationType)value == GutterCalculationType.Baseline)
            {
                if (((string)parameter).Contains("Baseline"))
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            if (value is GutterCalculationType && (GutterCalculationType)value == GutterCalculationType.Ratio)
            {
                if (((string)parameter).Contains("Ratio"))
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
